<?php
if (!$_pageblock) $_pageblock = 10;
if (!$_pagevar) $_pagevar = '共 <b>%s</b> 件物品';
if($list['page']):?>
<br clear="all" />
<div id="pages">
<?php printf($_pagevar, $list['page']['total']);?>
&nbsp; &nbsp;

<?php if($list['page']['perv']):?><a class="prev" tabindex="5" href="<?php echo $list['page']['url']?>p=<?php echo $list['page']['perv']?>">&#8249; 上一页</a>&nbsp;<?php endif;?>&nbsp;

<?php if ($list['page']['totalpage'] > 1) {
    $work['start'] = $list['page']['p'] - ceil($_pageblock/2);
    if ($work['start'] < 1) $work['start'] = 1;
    $work['end'] = $list['page']['p'] + ceil($_pageblock/2);
    if ( $work['end'] != $work['start'] + $_pageblock ) $work['end'] = $work['start'] + ($_pageblock-1);
    if ($work['end'] > $list['page']['totalpage']) $work['end'] = $list['page']['totalpage'];
    if ( $work['start'] != $work['end'] - $_pageblock ) $work['start'] = $work['end'] - ($_pageblock-1);
    if ($work['start'] < 1) $work['start'] = 1;
?>
<?php if ($work['start'] > 1):?><a tabindex="5" href="<?php echo $list['page']['url']?>p=<?php echo $list['page']['perv']?>">&laquo;</a>&nbsp;<?php endif;?>

<?php
    for ( $i_page = $work['start']; $i_page <= $work['end']; $i_page++ ) {
        if ($i_page == $list['page']['p']):
?>

<b class="currpage"><?php echo $i_page?></b>&nbsp;
<?php else:?>
<a class="otherpage" tabindex="5" href="<?php echo $list['page']['url']?>p=<?php echo $i_page?>"><?php echo $i_page?></a>&nbsp;
<?php
        endif;
    }
?>

<?php if ($work['end'] < $list['page']['totalpage']):?><a tabindex="5" href="<?php echo $list['page']['url']?>p=<?php echo $list['page']['next']?>">&raquo;</a>&nbsp;<?php endif;?>

<?php
}
?>

<?php if($list['page']['next']):?>&nbsp;&nbsp;<a class="next" tabindex="5" href="<?php echo $list['page']['url']?>p=<?php echo $list['page']['next']?>">下页更精彩 &#8250;</a><?php endif;?>
</div>
<?php endif;?>
